package sanrenxing.dayEnd.backRepertoryTotal.dao;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import sanrenxing.dayEnd.backRepertoryTotal.domain.ManagerSetup;

import java.util.List;
import java.util.Map;

/**
 * 功能：管理人数据层接口
 * 编写者：蒋玲苹
 * 日期：
 * 版本：1.0
 */
@Repository
public interface ManagerSetupDao {
    /**
     * 添加数据
     * @param managerSetup
     * @return  0:添加失败,1:添加成功
     */
    @Insert("insert into managerSetup values(seqManagerSetup.nextval,#{comName},#{comAddress},#{comNum},#{adminiName},#{adminRate})")
    public int add(ManagerSetup managerSetup);

    /**
     * 删除数据
     * @param adminId
     * @return 删除影响的行数(0:删除失败,1:删除成功)
     */
    @Delete("delete from managerSetup where adminId=#{adminId}")
    public int delete(@Param("adminId") int adminId);

    /**
     * 修改数据
     * @param managerSetup
     * @return
     */
    @Update("update managerSetup set comName=#{comName},comAddress=#{comAddress},comNum=#{comNum},adminiName=#{adminiName},adminRate=#{adminRate} where adminId=#{adminId}")
    public int update(ManagerSetup managerSetup);

    /**
     * 分页查询所有数据
     * @param map
     * @return
     */
    @Select("<script>" +
            "select * from " +
            " (select rownum rn,managerSetup.* from managerSetup " +
            " <where>#{end}>=rownum</where>)" +
            "<where>" +
            "<if test='managerSetup.adminiName!=null'>" +
            " and adminiName like '%${managerSetup.adminiName}%'" +
            "</if>" +
            "<if test='managerSetup.comName!=null'>" +
            " and comName like '%${managerSetup.comName}%'" +
            "</if>" +
            " and rn>=#{start}" +
            "</where>" +
            "</script>")
    public List<ManagerSetup>  queryAll(Map<String, Object> map);

    /**
     * 统计记录数
     * @return
     */
    @Select("select count(*) from managerSetup")
    public int count();
}
